<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="/resource/common.jsp"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<base href="<%=basePath%>">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>${title}</title>
		<link rel="stylesheet" type="text/css" href="<c:url value='/resource/css/jquery.tabs.css'/>"/>
		<script type="text/javascript" src="<c:url value='/resource/js/jquery.tabs.js'/>"></script>	
		<style type="text/css">
			body{
				margin: 0;
				padding: 0;
				line-height: 30px;
			}
			.td_tit{
				width:80px;
				text-align: right;
			}
			#update_table input{border:1px solid #ccc;}
			#basicInfo table,#pwdinfo table{margin:0px;padding:0px;}
		</style>
		<script type="text/javascript">
		
		$.extend($.fn.validatebox.defaults.rules, {  
		    /*必须和某个字段相等*/
		    equalTo: {
		        validator:function(value,param){
		            return $(param[0]).val() == value;
		        },
		        message:'字段不匹配'
		    }
		           
		});
		
		$(function(){
			$(".ui-layout-center").tabs();
			$("body").css({visibility:"visible"});
		});
		function submitForm(){
			
			
			if($("#update_table").form('validate')){
				top.mask();
				$("#update_table").ajaxSubmit({
					url:"<c:url value='/user/updatepwd.json'/>",
					type:"post",
					dataType:"json",
					data:{
						password:$("#password").val(),
						newPassword:$("#newPassword").val(),
						password_2:$("#password_2").val()
					},
					success:function(data){
						if(data.result=="0"){
							//art.dialog.tips("原始密码错误", 1.5);
							top.showMsg("原始密码错误");
							window.setTimeout(function() {
								//先关闭窗口
								//top.closeWin('ps');
								top.unmask();
							}, 1500);	
							
							
						}else{
							top.showMsg("修改密码成功");
							window.setTimeout(function() {
								//先关闭窗口
								top.closeWin('ps');
								top.unmask();
							}, 1500);
							//art.dialog.tips("修改密码成功", 1.5);
							//window.setTimeout(function(){
							//	art.dialog.close();
							//},1500);
						}
						
					},
					error:function(){
						art.dialog.tips("错误");
					}
				});
			}
			return 
			
			
			
			
			
			
			
			if($("#basicInfo :hidden").size()==0){
				art.dialog.close();
			}else{
				if($("#password").val()==""){
					art.dialog.tips("请输入原始密码");
					return ;
				}
				if($("#newPassword").val()==""){
					art.dialog.tips("请输入新密码");
					return ;
				}
				if($("#newPassword").val()!=$("#password_2").val()){
					art.dialog.tips("两次输入密码不一致");
					return ;
				}
				top.mask();
				$("#update_table").ajaxSubmit({
					url:"<c:url value='/user/updatepwd.json'/>",
					type:"post",
					dataType:"json",
					data:{
						password:$("#password").val(),
						newPassword:$("#newPassword").val(),
						password_2:$("#password_2").val()
					},
					success:function(data){
						if(data.result=="0"){
							//art.dialog.tips("原始密码错误", 1.5);
							top.showMsg("原始密码错误");
							window.setTimeout(function() {
								//先关闭窗口
								//top.closeWin('ps');
								top.unmask();
							}, 1500);	
							
							
						}else{
							top.showMsg("修改密码成功");
							window.setTimeout(function() {
								//先关闭窗口
								top.closeWin('ps');
								top.unmask();
							}, 1500);
							//art.dialog.tips("修改密码成功", 1.5);
							//window.setTimeout(function(){
							//	art.dialog.close();
							//},1500);
						}
						
					},
					error:function(){
						art.dialog.tips("错误");
					}
				});
			}
		}
		</script>
	</head>


	<body >
		<div class="ui-layout-center">
			<div>
				<h2 class="ui-tab">
					<span id="page1" class="ui-tab-curr">基本信息</span>
					<span id="page2">修改密码</span>
				</h2>
			</div>
			<div class="ui-tab-panels">
				<div id="basicInfo" class="ui-tab-panel ui-tab-curr">
					<table>
						<tr>
							<td class="td_tit">警号:</td>
							<td>${_SESSION_LOGIN_USER.policeNum }</td>
						</tr>
						<tr>
							<td class="td_tit">姓名:</td>
							<td>${_SESSION_LOGIN_USER.name }</td>
						</tr>
						<tr>
							<td class="td_tit">部门:</td>
							<td>${_SESSION_LOGIN_USER.deptName }</td>
						</tr>
					</table>
				</div>
				<div id="pwdinfo" class="ui-tab-panel">
					<table id="update_table">
						<tr>
							<td class="td_tit">原始密码:</td>
							<td><input style="width:254px" data-options='required:true,tipPosition:"bottom",missingMessage:"请输入旧密码"'  style="width:200px;"  name="ordernum" value="${0 == data.ordernum ? '':data.ordernum}" class="easyui-validatebox" required="true" maxlength="15" id="password" type="password"></input></td>
						</tr>
						<tr>
							<td class="td_tit">新密码:</td>
							<td><input style="width:254px" data-options='required:true,tipPosition:"bottom",missingMessage:"请输入新密码"'  style="width:200px;"  name="ordernum" value="${0 == data.ordernum ? '':data.ordernum}" maxlength="15" id="newPassword" class="easyui-validatebox" required="true"  type="password"></input></td>
						</tr>
						<tr>
							<td class="td_tit">再次输入密码:</td>
							<td><input style="width:254px" maxlength="15" class="easyui-validatebox" data-options='required:true,tipPosition:"bottom",missingMessage:"请输入确认密码"'  style="width:200px;"  name="ordernum" value="${0 == data.ordernum ? '':data.ordernum}" validType="equalTo['#newPassword']" invalidMessage="两次输入密码不匹配" id="password_2" type="password"></input></td>
						</tr>
					</table>
				</div>
			</div>
		</div>
	</body>
</html>